package com.shu.socket.BIO;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author ssm
 * @version V1.0
 * @description:
 * @date 2019/2/20 19:40
 */

public class SocketServer {

  public static void main(String[] args) throws IOException {
    //
    ServerSocket servrSocket = null;

    try {
      servrSocket = new ServerSocket(8888);

      Socket socket = servrSocket.accept();//阻塞

      BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));

      System.out.println(reader.readLine());
      reader.close();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (servrSocket != null) {
        servrSocket.close();
      }
    }

  }
}
